﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using Intorise.API;
using Intorise.Common;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Diagnostics;
using Intorise.Net;
using System.IO;
using Config;

namespace WowAnswerCheckApp
{
    public partial class Main : Form
    {
        NetTools netTools = new NetTools();

        string sourceFileName = "";//加载账户的文件名
        string sourcePath = "";
        string STATUS_FORMAT = "检测帐号{0}/{1}，字典索引{2}/{3}，用时：{4}，速度：{5}次/小时，预计{6}后完成";
        string[] loginUrls = new string[4];

        bool completed = false;
        bool paused = false;
        int currentIndex = 0;
        int currentCheckCount = 0;
        int currentUrlIndex = 0;//
        int totalCheckCount = 0;//总检测次数=字典数量*账户数量
        int completedCheckCount = 0;//已完成的检测
        int maxTimeoutCount = 3;//检测时出现超时的最大检测次数
        int maxForbidCount = 10;//出现尝试次数太多的最大检测次数
        List<Account> accounts = new List<Account>();
        TimeSpan timeout = new TimeSpan(0, 0, 30);//超时
        int waitMin = 60;//检测次数太多的帐号等待下次检测的间隔为3分钟

        object autoSaveLocker = new object();
        System.Threading.Timer autoSaveTimer = null;//自动保存数据的计时器
        Loger loger = new Loger(AppDomain.CurrentDomain.BaseDirectory + "\\log.txt");
        DateTime processBeginDateTime;

        public Main()
        {
            InitializeComponent();
            netTools.CheckNetStatusServer = "www.baidu.com";
            autoSaveTimer = new System.Threading.Timer(new TimerCallback(this.AutoSaveMethod), null, Timeout.Infinite, 3000);
            loginUrls[0] = "https://tw.battle.net/account/support/identify-account.html?requestType=PASSWORD_RESET";
            loginUrls[1] = "https://us.battle.net/account/support/identify-account.html?requestType=PASSWORD_RESET";
            loginUrls[2] = "https://eu.battle.net/account/support/identify-account.html?requestType=PASSWORD_RESET";
            loginUrls[3] = "https://kr.battle.net/account/support/identify-account.html?requestType=PASSWORD_RESET";
            ConsoleBLL.Log = loger;
        }

        private void Main_Load(object sender, EventArgs e)
        {
            DictForm.LoadDict();
            LoadLastCheck();
        }

        private void LoadLastCheck()
        {
            FileInfo file = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "\\" + "待测.txt");
            if (!file.Exists) { return; }
            if (file.Length > 0)
            {
                var result = MessageBox.Show("上次有检测未完成的数据，是否加载？", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);
                if (result != DialogResult.Yes)
                {
                    return;
                }
            }
            FillLastCheckAccounts(file.FullName, accounts);
            ConsoleBLL.WriteLineWaring("已加载" + accounts.Count + "个账户");
        }

        private void Start()
        {
            if (currentIndex >= accounts.Count)//最后一个帐号
            {
                bool flag = true;
                foreach (Account account in accounts)
                {
                    if (account.Status == CheckStatus.Wait) { flag = false; break; }
                }
                if (flag)//全部完成
                {
                    Finsh();
                    return;
                }
                currentIndex = 0; currentCheckCount = 0;
            }
            ConsoleBLL.WriteLineInfo(string.Format("开始检测...帐号：{0}/{1}", currentIndex + 1, accounts.Count));
            completed = false;

            if (currentUrlIndex > 3)
            {
                currentUrlIndex = 0;
            }
            this.web1.Url = new Uri("about:blank");
            WebBrowserTools.ClearCookie(web1);
            this.web1.Url = new Uri(loginUrls[currentUrlIndex++]);
            BeginCheck();
        }

        private void BeginCloseAlertWindow()
        {
            Thread thread = new Thread(new ParameterizedThreadStart(x =>
            {
                while (!completed)
                {
                    var pointer = Windows.FindWindowEx(IntPtr.Zero, IntPtr.Zero, null, "安全警报");
                    if (pointer != IntPtr.Zero)
                    {
                        Intorise.API.Helper.SendKeyPress(pointer, Keys.Enter);
                    }
                    pointer = Windows.FindWindowEx(IntPtr.Zero, IntPtr.Zero, null, "脚本错误");
                    if (pointer != IntPtr.Zero)
                    {
                        Intorise.API.Helper.SendKeyPress(pointer, Keys.Enter);
                    }
                    Thread.Sleep(300);
                }
                ConsoleBLL.WriteLine("关闭安全警报完成");
            }));
            thread.Start();
        }

        private void BeginCheck()
        {
            Thread thread = new Thread(new ParameterizedThreadStart(x =>
            {
                while (!netTools.CheckNetStatus())
                {
                    while (!Program.ADSL.Connect())
                    {
                        Thread.Sleep(100);
                        Application.DoEvents();
                    }
                }
                try
                {
                    if (BeginInputEmail())
                    {
                        if (BeginInputAnswer())
                        {
                            CheckAnswer();
                        }
                    }
                }
                catch (Exception ex)
                {
                    ConsoleBLL.WriteLineError("出现了错误，跳过了当前帐号的检测");
                    ConsoleBLL.WriteLineError(ex.Message);
                    ConsoleBLL.WriteLineError(ex.StackTrace);
                }
                Start();
            }));
            thread.Name = "CheckThread";
            thread.Start();
        }

        private void SetStatus(string text)
        {
            this.statusLabel.Text = text;
        }

        private bool BeginInputEmail()
        {
            Pause();
            var time = DateTime.Now - processBeginDateTime;
            var speed = (int)(completedCheckCount / time.TotalHours);
            double needHours = 0;
            if (speed > 0)
            {
                needHours = Math.Round((totalCheckCount - completedCheckCount) / completedCheckCount / time.TotalHours, 2);
            }
            string text = string.Format(STATUS_FORMAT, currentIndex + 1, accounts.Count, accounts[currentIndex].DictIndex + 1,
                    Program.AnswerDict.Count, Math.Round(time.TotalHours, 2),
                    speed, needHours == 0 ? "很久" : needHours.ToString() + "小时");
            this.Invoke(new Action<string>(SetStatus), text);

            if (currentCheckCount > 3)
            {
                ConsoleBLL.WriteLineWaring("当前账号已经检测了3次，跳过！");
                SkipCurrent();
                return false;
            }
            if (accounts[currentIndex].Status == CheckStatus.Completed || accounts[currentIndex].Status == CheckStatus.Success)
            {
                return SkipCurrent();
            }
            if (accounts[currentIndex].TimeoutCount > maxTimeoutCount)
            {
                return IgnoreCurrent("超时次数超限");
            }
            if (accounts[currentIndex].ForbidCount > 0)//此帐号已出现尝试次数太多
            {
                if (accounts[currentIndex].ForbidCount > maxForbidCount)//超过10次不在检测
                {
                    ConsoleBLL.WriteLineWaring(string.Format("帐号{0}已出现{1}次尝试太多的信息，不再检测此帐号", accounts[currentIndex], accounts[currentIndex].ForbidCount));
                    return IgnoreCurrent("因尝试太多而测试失败");
                }
                time = DateTime.Now - accounts[currentIndex].LastCheckTime;
                var needWaitTime = new TimeSpan(0, accounts[currentIndex].ForbidCount * waitMin, 0);
                if (time < needWaitTime)
                {
                    ConsoleBLL.WriteLineWaring(string.Format("帐号{0}已出现{1}次尝试太多的信息，等待{2}后检测", accounts[currentIndex], accounts[currentIndex].ForbidCount, needWaitTime - time));
                    Thread.Sleep(1000);
                    Application.DoEvents();
                    return SkipCurrent();
                }
                accounts[currentIndex].ForbidCount = 0;
            }
            if (accounts[currentIndex].DictIndex >= Program.AnswerDict.Count)
            {
                accounts[currentIndex].CheckInfo = "未找到答案"; accounts[currentIndex].Status = CheckStatus.Completed; return SkipCurrent();
            }
            ConsoleBLL.WriteLineWaring(string.Format("开始检测第{0}个帐号：{1}，词典索引：{2}", currentIndex, accounts[currentIndex].Username, accounts[currentIndex].DictIndex));


            currentCheckCount++;
            ConsoleBLL.WriteLineInfo("开始输入邮箱");
            accounts[currentIndex].LastCheckTime = DateTime.Now;
            HtmlElement email = null;
            HtmlElement button = null;

            DateTime beginTime = DateTime.Now;
            bool timeouted = true;
            while (DateTime.Now - beginTime < timeout)
            {
                string documentText = GetDocumentText();
                if (documentText.Contains("你已經嘗試太多次"))
                {
                    ConsoleBLL.WriteLineWaring("尝试次数太多，换IP重新检测！");
                    accounts[currentIndex].CheckInfo = "尝试太多";
                    accounts[currentIndex].ForbidCount++;//记录出现尝试次数太多的次数
                    CheckNeedReconnect();
                    return false;
                }
                if (documentText.Contains("請輸入圖像中的代碼"))
                {
                    ConsoleBLL.WriteLineWaring("出现验证码，换IP重新检测！");
                    CheckNeedReconnect();
                    return false;
                }
                if (documentText.Contains("帳號不適用於帳號恢復"))
                {
                    return IgnoreCurrent("帳號不適用於帳號恢復");
                }
                if (documentText.Contains("請輸入你用來申請簡訊通知服務"))
                {
                    return IgnoreCurrent("需要电话号码");
                }
                if (documentText.Contains("透過快速的安全檢查"))
                {
                    return IgnoreCurrent("需要安全码");
                }
                email = GetHtmlElement("email");
                button = GetHtmlElement("support-submit");
                if (email != null && button != null)
                {
                    timeouted = false;
                    break;
                }
                Thread.Sleep(300);
                //Application.DoEvents();
            }
            if (timeouted)
            {
                ConsoleBLL.WriteLineWaring("查找邮箱输入框和按钮超时，跳过！");
                accounts[currentIndex].CheckInfo = "邮箱输入超时";
                accounts[currentIndex].TimeoutCount++;
                return false;
            }

            this.Invoke(new Action(() =>
            {
                email.SetAttribute("value", accounts[currentIndex].Username);
                //email.SetAttribute("value", accounts[currentIndex].Username);
                button.InvokeMember("click");
                //button.InvokeMember("click");
            }));
            ConsoleBLL.WriteLineInfo("邮箱输入完成");
            return true;
        }

        private bool BeginInputAnswer()
        {
            Pause();
            ConsoleBLL.WriteLineInfo("开始输入答案");
            HtmlElement answer = null;
            HtmlElement button = null;
            DateTime beginTime = DateTime.Now;
            bool timeouted = true;
            while (DateTime.Now - beginTime < timeout)
            {
                string documentText = GetDocumentText();
                if (documentText.Contains("找不到帳號"))
                {
                    ConsoleBLL.WriteLineWaring("找不到此帳號！");
                    accounts[currentIndex].CheckInfo = "帐号错误";
                    accounts[currentIndex].Status = CheckStatus.Completed;
                    return SkipCurrent();
                }
                if (documentText.Contains("你已經嘗試太多次"))
                {
                    ConsoleBLL.WriteLineWaring("此账户尝试次数太多，将稍后再试");
                    accounts[currentIndex].CheckInfo = "尝试太多";
                    accounts[currentIndex].ForbidCount++;//记录出现尝试次数太多的次数
                    return SkipCurrent();
                }
                if (documentText.Contains("基於安全性考量") || documentText.Contains("請輸入圖像中的代碼"))
                {
                    ConsoleBLL.WriteLineWaring("出现验证码，换IP重新检测！");
                    CheckNeedReconnect();
                    return false;
                }
                if (documentText.Contains("帳號不適用於帳號恢復"))
                {
                    return IgnoreCurrent("帳號不適用於帳號恢復");
                }
                if (documentText.Contains("請輸入你用來申請簡訊通知服務"))
                {
                    return IgnoreCurrent("需要电话号码");
                }
                if (documentText.Contains("透過快速的安全檢查"))
                {
                    return IgnoreCurrent("需要安全码");
                }
                answer = GetHtmlElement("answer");
                button = GetHtmlElement("support-submit");
                if (answer != null && button != null)
                {
                    timeouted = false;
                    break;
                }
                Thread.Sleep(300);
                //Application.DoEvents();
            }

            if (timeouted)
            {
                ConsoleBLL.WriteLineWaring("查找问题输入框和按钮超时，跳过！");
                accounts[currentIndex].CheckInfo = "问题输入超时";
                accounts[currentIndex].TimeoutCount++;
                return SkipCurrent();
            }
            this.Invoke(new Action(() =>
            {
                answer.SetAttribute("value", Program.AnswerDict[accounts[currentIndex].DictIndex]);
                button.InvokeMember("click");
            }));
            ConsoleBLL.WriteLineInfo("答案输入完成");
            return true;
        }

        private void CheckAnswer()
        {
            Pause();
            ConsoleBLL.WriteLineInfo("开始检测结果");
            DateTime beginTime = DateTime.Now;
            bool timeouted = true;
            while (DateTime.Now - beginTime < timeout)
            {
                string documentText = GetDocumentText();
                if (documentText.Contains("郵件已經寄到你的 Battle.net 註冊信箱。"))
                {
                    accounts[currentIndex].Answer = Program.AnswerDict[accounts[currentIndex].DictIndex];
                    accounts[currentIndex].CheckInfo = "重置成功";
                    accounts[currentIndex].Status = CheckStatus.Success;
                    ConsoleBLL.WriteLineInfo("重置成功！");
                    completedCheckCount++; this.progressBar.Value++;
                    timeouted = false; break;
                }
                else if (documentText.Contains("密碼提示答案錯誤"))
                {
                    accounts[currentIndex].DictIndex++;//下一个词典
                    accounts[currentIndex].CheckInfo = "答案错误";
                    ConsoleBLL.WriteLineInfo("密保答案错误！");
                    completedCheckCount++; this.progressBar.Value++;
                    timeouted = false; break;
                }
                if (documentText.Contains("透過快速的安全檢查"))
                {
                    IgnoreCurrent("需要安全码"); return;
                }
                if (documentText.Contains("請輸入一個有效的電話號碼"))
                {
                    IgnoreCurrent("需要手机号"); return;
                }
                //Application.DoEvents();
                Thread.Sleep(300);
            }
            if (timeouted)
            {
                accounts[currentIndex].CheckInfo = "检测答案超时";
                ConsoleBLL.WriteLineError("检测密码提示答案超时！");
                accounts[currentIndex].TimeoutCount++;
            }
            //记录结果
            ConsoleBLL.WriteLineInfo("检测结果完成");
        }

        private bool SkipCurrent()
        {
            currentIndex++;
            currentCheckCount = 0;
            return false;
        }

        private bool IgnoreCurrent(string info)
        {
            var count = Program.AnswerDict.Count - accounts[currentIndex].DictIndex;
            totalCheckCount -= count;
            completedCheckCount++;
            this.progressBar.Value++;
            this.progressBar.Maximum = totalCheckCount;
            accounts[currentIndex].Status = CheckStatus.Ignore;
            accounts[currentIndex].CheckInfo = info;
            currentIndex++;
            currentCheckCount = 0;
            return false;
        }

        private void CheckNeedReconnect()
        {
            ConsoleBLL.WriteLineInfo("开始重新拨号！");
            int count = 0;
            var success = false;
            while (count < 10)
            {
                success = Program.ADSL.ConnectAndCheckIP();
                if (success)
                {
                    break;
                }
                ConsoleBLL.WriteLineError("无法拨号和获取新的IP，重试！");
                count++;
            }
            if (!success)
            {
                ConsoleBLL.WriteLineError("重试10此都无法获取新的IP！"); return;
            }
            ConsoleBLL.WriteLineInfo("拨号更换IP成功！");
        }
        private string GetDocumentText()
        {
            return (string)this.Invoke(new Func<string>(() =>
            {
                return web1.DocumentText;
            }));
        }
        private HtmlElement GetHtmlElement(string id)
        {
            //return web1.Document.GetElementById(id);
            return (HtmlElement)this.Invoke(new Func<HtmlElement>(() =>
            {
                return web1.Document.GetElementById(id);
            }));
        }

        #region event handler
        private void 字典设置ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DictForm form = new DictForm();
            form.ShowDialog();
        }

        private void 系统设置ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            new ConfigForm().ShowDialog();
        }

        private void 开始ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Program.AnswerDict.Count == 0)
            {
                MessageBox.Show("没有加载字典，请设置字典！"); return;
            }
            if (accounts.Count == 0)
            {
                MessageBox.Show("没有加载账户，请先加载账户！"); return;
            }
            this.开始ToolStripMenuItem.Enabled = false;
            this.加载账户ToolStripMenuItem.Enabled = false;
            this.字典设置ToolStripMenuItem.Enabled = false;
            processBeginDateTime = DateTime.Now;
            totalCheckCount = accounts.Count * Program.AnswerDict.Count;
            this.progressBar.Maximum = totalCheckCount;
            currentCheckCount = 0;
            currentIndex = 0;
            paused = false;
            if (ConfigManager.AppConfig.AutoSaveTime > 0)
            {
                this.autoSaveTimer.Change(60000, ConfigManager.AppConfig.AutoSaveTime * 60000);
            }
            BeginCloseAlertWindow();
            Start();
            this.暂停ToolStripMenuItem.Enabled = true;
        }

        private void 加载账户ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult result;
            string[] fileNames = sender as string[];
            if (fileNames != null)
            {
                result = DialogResult.OK;
            }
            else
            {
                result = this.openFileDialog1.ShowDialog();
                fileNames = this.openFileDialog1.FileNames;
            }

            if (result != DialogResult.OK)
            {
                return;
            }
            sourceFileName = new FileInfo(fileNames[0]).DirectoryName + "\\" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".txt";
            accounts.Clear();
            for (int i = 0; i < fileNames.Length; i++)
            {
                try
                {
                    FillAccounts(fileNames[i], accounts, false);
                }
                catch (Exception ex)
                {
                    if (MessageBox.Show("加载账户文件" + fileNames[i] + "时出错，您需要在重新加载这个文件吗？", "加载账户出错", MessageBoxButtons.OKCancel, MessageBoxIcon.Error) == DialogResult.OK)
                    {
                        i--;
                    }
                    ConsoleBLL.WriteLineWaring(ex.Message);
                }
            }

            ConsoleBLL.WriteLineWaring("已加载" + accounts.Count + "个账户");
            
        }

        private void 暂停ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (暂停ToolStripMenuItem.Text == "暂停")
            {
                paused = true;
                暂停ToolStripMenuItem.Text = "继续";
                ConsoleBLL.WriteLineWaring("正在暂停检测...");
            }
            else
            {
                paused = false;
                暂停ToolStripMenuItem.Text = "暂停";
            }
        }

        private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.statusLabel.Text = "保存数据，请稍后！";
            AutoSaveMethod(null);
            this.Close();
        }
        #endregion

        void Pause()
        {
            var flag = paused;
            if (flag)
            {
                ConsoleBLL.WriteLineWaring("检测已经暂停...");
            }
            while (paused)
            {
                Application.DoEvents();
                Thread.Sleep(100);
            }
            if (flag)
            {
                ConsoleBLL.WriteLineWaring("检测继续...");
            }
        }

        static void FillAccounts(string filename, List<Account> list, bool clear)
        {
            if (list == null)
            {
                list = new List<Account>();
            }
            else
            {
                if (clear)
                {
                    list.Clear();
                }
            }

            StreamReader sr = null;
            try
            {
                sr = new StreamReader(filename, Encoding.Default);
            }
            catch
            {
                throw;
            }
            try
            {
                while (!sr.EndOfStream)
                {
                    string[] items = sr.ReadLine().Split(new char[] { ' ', '\t', ',' }, StringSplitOptions.RemoveEmptyEntries);
                    if ((items.Length > 0))
                    //if ((items.Length == 2) && (items[1].Length > 4))
                    {
                        Account account = new Account();
                        account.Username = items[0];
                        account.CheckInfo = "待检测";
                        account.Status = CheckStatus.Wait;
                        list.Add(account);
                    }
                }
                sr.Close();
            }
            catch
            {
                if (sr != null)
                {
                    sr.Close();
                }
                throw;
            }
        }

        static void FillLastCheckAccounts(string filename, List<Account> list)
        {
            if (list == null)
            {
                list = new List<Account>();
            }

            StreamReader sr = null;
            try
            {
                sr = new StreamReader(filename, Encoding.Default);
            }
            catch
            {
                throw;
            }
            int dictIndex = 0;
            CheckStatus status;
            try
            {
                while (!sr.EndOfStream)
                {
                    string[] items = sr.ReadLine().Split(new char[] { ' ', '\t', ',' }, StringSplitOptions.RemoveEmptyEntries);
                    if ((items.Length > 2))
                    //if ((items.Length == 2) && (items[1].Length > 4))
                    {
                        Account account = new Account();
                        account.Username = items[0];
                        if (Enum.TryParse<CheckStatus>(items[1], out status))
                        {
                            account.Status = status;
                        }

                        if (int.TryParse(items[2], out dictIndex))
                        {
                            account.DictIndex = dictIndex;
                        }
                        list.Add(account);
                    }
                }
                sr.Close();
            }
            catch
            {
                if (sr != null)
                {
                    sr.Close();
                }
                throw;
            }
        }

        /// <summary>
        /// 保存数据
        /// </summary>
        void SaveResult(string sourceFileName, List<Account> resultList)
        {
            ConsoleBLL.WriteLineInfo("开始保存数据....");
            StringBuilder sbSuccess = new StringBuilder();
            StringBuilder sbComplete = new StringBuilder();
            StringBuilder sbWaiting = new StringBuilder();
            StringBuilder sbIgnore = new StringBuilder();
            string destFileName = "";


            foreach (Account aclv in resultList)
            {
                if (aclv.Status == CheckStatus.Success)
                {
                    sbSuccess.Append(aclv.Username).Append("\t").AppendLine(aclv.Answer);
                }
                else if (aclv.Status == CheckStatus.Completed)
                {
                    sbComplete.Append(aclv.Username).Append("\t").AppendLine(aclv.CheckInfo);
                }
                else if (aclv.Status == CheckStatus.Ignore)
                {
                    sbIgnore.Append(aclv.Username).Append("\t").AppendLine(aclv.CheckInfo);
                }
                sbWaiting.Append(aclv.Username).Append("\t").Append(aclv.Status).Append("\t").AppendLine(aclv.DictIndex.ToString());
            }
            if (sbSuccess.Length > 0)
            {
                destFileName = sourceFileName + "_正确.txt";
                StreamWriter writer = new StreamWriter(destFileName, false);
                writer.Write(sbSuccess.ToString());
                writer.Close();
            }
            if (sbComplete.Length > 0)
            {
                destFileName = sourceFileName + "_错误.txt";
                StreamWriter writer = new StreamWriter(destFileName, false);
                writer.Write(sbComplete.ToString());
                writer.Close();
            }
            if (sbIgnore.Length > 0)
            {
                destFileName = sourceFileName + "_跳过.txt";
                StreamWriter writer = new StreamWriter(destFileName, false);
                writer.Write(sbIgnore.ToString());
                writer.Close();
            }
            if (sbWaiting.Length > 0)
            {
                destFileName = AppDomain.CurrentDomain.BaseDirectory + "\\待测.txt";
                StreamWriter writer = new StreamWriter(destFileName, false);
                writer.Write(sbWaiting.ToString());
                writer.Close();
            }
            else
            {
                File.Delete(AppDomain.CurrentDomain.BaseDirectory + "\\待测.txt");
            }
            ConsoleBLL.WriteLineInfo("保存数据....OK");
        }

        //自动保存数据方法
        private void AutoSaveMethod(object o)
        {
            lock (autoSaveLocker)
            {
                lock (autoSaveLocker)
                {
                    SaveResult(this.sourceFileName, this.accounts);
                }
            }
        }

        private void Finsh()
        {
            completed = true;
            this.autoSaveTimer.Change(Timeout.Infinite, Timeout.Infinite);
            SaveResult(sourceFileName, accounts);
            ConsoleBLL.WriteLineInfo("所有账户测试完成！");
            MessageBox.Show("所有账户测试完成！");
            this.开始ToolStripMenuItem.Enabled = true;
            this.加载账户ToolStripMenuItem.Enabled = true;
            this.字典设置ToolStripMenuItem.Enabled = true;
            this.暂停ToolStripMenuItem.Enabled = false;
            paused = false;
            AutoSaveMethod(null);
            this.progressBar.Value = 0;
            File.Delete(AppDomain.CurrentDomain.BaseDirectory + "\\" + "待测.txt");
        }
    }
}
